﻿namespace TriangleGames.TrainResEditor
{
    using TriangleGames.TrainRes;
    using System;
    using System.Runtime.CompilerServices;
    using UnityEditor;

    internal static class GameStateTracker
    {
        [CompilerGenerated]
        private static GameState CurrentState__BackingField;
        [CompilerGenerated]
        private static GameState PreviousState__BackingField;

        private static GameState GetCurrentState()
        {
            PreviousState = CurrentState;
            if (EditorApplication.isPaused)
            {
                if (Fsm.IsErrorBreak)
                {
                    return GameState.Error;
                }
                if (Fsm.IsBreak)
                {
                    return GameState.Break;
                }
                return GameState.Paused;
            }
            if (!EditorApplication.isPlaying)
            {
                return GameState.Stopped;
            }
            return GameState.Running;
        }

        public static void Update()
        {
            PreviousState = CurrentState;
            CurrentState = GetCurrentState();
        }

        public static GameState CurrentState
        {
            [CompilerGenerated]
            get
            {
                return CurrentState__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                CurrentState__BackingField = value;
            }
        }

        public static GameState PreviousState
        {
            [CompilerGenerated]
            get
            {
                return PreviousState__BackingField;
            }
            [CompilerGenerated]
            private set
            {
                PreviousState__BackingField = value;
            }
        }

        public static bool StateChanged
        {
            get
            {
                return (CurrentState != PreviousState);
            }
        }
    }
}

